import board
import busio
import digitalio
from adafruit_ssd1306 import SSD1306_SPI
import time
from fonts import *


OLED_CLK = board.GP18
OLED_MOSI = board.GP19

useless1 = digitalio.DigitalInOut(board.GP44)
useless1.direction = digitalio.Direction.INPUT

useless2 = digitalio.DigitalInOut(board.GP45)
useless2.direction = digitalio.Direction.INPUT

'''
CS_N 41
DC 42
RESET 43
DIN 44
CLK 45
'''

OLED_CS_N = digitalio.DigitalInOut(board.GP41)
OLED_DC = digitalio.DigitalInOut(board.GP42)
OLED_RESET = digitalio.DigitalInOut(board.GP43)
spi = busio.SPI(clock=OLED_CLK, MOSI=OLED_MOSI)

oled = SSD1306_SPI(128, 32, spi, OLED_DC, OLED_RESET, OLED_CS_N)

oled.fill(0)


num_pos1_x = 10
num_pos1_y = 10
wave_pos_x = 5
wave_pos_y = 10


'''
# 坐标位置测试
# 到左上角的位置
# 第一个参数为列，第二个参数为行
oled.pixel(5,10,1)
oled.show()
'''

'''
# 显示数字测试
while True:
    for i in [0,1,2,3,4,5,6,7,8,9,"=","F","k","H","z","A","V","."]:
        font = num_fonts[str(i)]
        oled.fill_rect(num_pos1_x, num_pos1_x, num_pos1_x+7, num_pos1_x+5, 0)
        for i,j in font:
            oled.pixel(j+num_pos1_y,i+num_pos1_x,1)
        oled.show()
        time.sleep(0.5)

'''
'''
# 波形绘制测试
while True:
    for t in range(4):
        font = wave_fonts[str(t)]
        
        oled.fill_rect(wave_pos_x, wave_pos_y, wave_pos_x+40, wave_pos_y+8, 0)
        for i,j in font:
            oled.pixel(i+wave_pos_x,j+wave_pos_y,1)
        oled.show()
        time.sleep(1)
'''



